import {Component, OnInit} from '@angular/core';
import {MessageService} from '../../service/message.service';
import {AlertMessage} from '../../entity/alert-message';

@Component({
    selector: 'app-site-message',
    templateUrl: './site-message.component.html',
    styleUrls: ['./site-message.component.css']
})
export class SiteMessageComponent implements OnInit {
    /**
     * 站内信息列表
     */
    messages: AlertMessage[] = [];

    constructor(private messageService: MessageService) {
    }

    ngOnInit() {
        this.messageService.messageProvider.subscribe(messages => {
            return this.messages = messages;
        });
    }

    remove(message: AlertMessage): void {
        this.messageService.remove(message);
    }
}
